package com.ty.day1;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/22 11:43
 */
public class Two {
    public static void main(String[] args) {
        char[] zf =Two.zf();
        String str="";
        Random random = new Random();
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            int nextInt = random.nextInt(zf.length);
            str=str+zf[nextInt];
        }
        System.out.println("输入验证码("+str+")");
        String input=sc.next();
        while (!str.equalsIgnoreCase(input)){
            System.out.println("重新输入：");
            input=sc.next();
        }
        System.out.println("验证码正确");
    }
    static char[] zf(){
        char[] a = new char[62];
        int x=0;
        for (char i='a';i<='z';i++){
            a[x++]=i;
        }
        for (char i='A';i<='Z';i++){
            a[x++]=i;
        }
        for (char i='0';i<='9';i++){
            a[x++]=i;
        }
        return a;
    }
}
